﻿@using Models
@model Users

@{
    ViewBag.Title = "Add user";
}
<div style="float: left; height: 70px"><a href="/admin/index" ><img src="/Content/images/back.png" /></a></div>
<div style="float: left; margin-left: 15px; text-align: center; width: 100px"><a href="/admin/AddUser" ><img src="/content/images/user_add.png" alt="Add user" /><br />Add user</a></div>
<div style="margin-left: 170px; text-align: center; width: 100px"><a href="/admin/AllUsers" ><img src="/content/images/users_group.png" alt="All users" /><br />All users</a></div>

<h2>Add user</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@if (ViewBag.Message != null)
{
    @ViewBag.Message
}
else
{
    using (Html.BeginForm("AddUser", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary()
        ;
        <table>
            <tr>
                <td>
                    @Html.LabelFor(x => x.Login)
                </td>
                <td>
                    @Html.TextBoxFor(x => x.Login)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.Pwd)
                </td>
                <td>
                    @Html.PasswordFor(x => x.Pwd)
                </td>
            </tr>
             <tr>
            <td>
                @Html.LabelFor(x => x.ConfirmPwd)
            </td>
            <td>
                @Html.PasswordFor(x => x.ConfirmPwd)
            </td>
        </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.Email)
                </td>
                <td>
                    @Html.TextBoxFor(x => x.Email)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.Role)
                </td>
                <td>
                    @{
                        var roles = new List<Role>
                                        {
                                            new Role{Id = 1, Name = "Administrator"},
                                            new Role{Id = 2, Name = "Editor"},
                                            new Role{Id = 3, Name = "User"}
                                        };
                        @Html.DropDownListFor(x => x.Role, new SelectList(roles,"Id","Name",1))
                    }
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.Name)
                </td>
                <td>
                    @Html.TextBoxFor(x => x.Name)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.FName)
                </td>
                <td>
                    @Html.TextBoxFor(x => x.FName)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.MName)
                </td>
                <td>
                    @Html.TextBoxFor(x => x.MName)
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="file" id="fileUpload" name="fileUpload"/>
                </td>
            </tr>
        </table>


        <input type="submit" name="subAddUser" value="add" />
    }
}